<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<%@include file="/WEB-INF/common/hplus-css.jsp"%>
<link href="${path}/assets/hplus/css/plugins/jqgrid/ui.jqgrid.css?0820"
	rel="stylesheet">
<link href="${path}/assets/static/css/global.css" rel="stylesheet"> 
</head>
<body>
<!-- 顶部导航开始 -->
<c:if test="${User.type eq '2'  }">
	<%@include file="/WEB-INF/common/header.jsp"%>
</c:if>
<!-- 顶部导航结束 -->
	<div class="wrapper wrapper-content  animated fadeInRight">
		<div class="row">
			<div class="col-sm-12">
				<div class="ibox ">
					<div class="ibox-title">
						<h5>公告信息管理</h5>
						<c:if test="${User.type eq '2'  }">
							<a href="javascript:history.back(-1)" class="back">
								<div class="center-topssss " style="margin-top: -10px;">
									<b>返回</b>
								</div>
							</a>
					</c:if>
					</div>
					<div class="ibox-content">
						<form action="${path}/article/query" role="form"
							class="form-inline query-form">
							<div class="form-group">
								<label for="exampleInputPassword2" class="sr-only">标题</label> <input
									type="text" placeholder="请输入标题" id="title" name="title"
									class="form-control" style="width: 237px; height: 46px">
							</div>

							<div class="form-group">
								<select class="form-control" id="status" name="status"
									style="width: 240px; height: 46px">
									<option value="">请选择状态</option>
									<option value="2">存草稿</option>
									<option value="1">已发布</option>
								</select>
							</div>
							<div class="form-group">
								<select class="form-control" id="genreCode" name="genreCode"
									style="width: 241px; height: 46px">
									<option value="">请选择所属类别</option>
									 <option value="0">登录首页幻灯片</option>
                                        <option value="1">政策信息</option>
                                        <option value="2" >排爆状态</option>
                                         <option value="3" >首页轮播幻灯片</option>
                                         <option value="4" >封面大图</option>
                                         <option value="5">用户指南</option>
								</select>
							</div>
							<button type="button" id="btn-query" class="btn btn-primary">搜索</button>
							<button type="button" id="btn-add" class="btn btn-primary"
								style="background-color: #1E9FFF;">添加内容</button>
							<!-- <button type="button" id="btn-dels" class="btn btn-primary" style="background-color: #FF5722;">批量删除</button> -->
						</form>
						<div>
							<%--<button type="button" id="btn-cancel" class="btn btn-success " value="3">注销</button>--%>
							<%--<button type="button" id="btn-lock" class="btn btn-success " value="5">锁定</button>--%>

							<%--<button type="button" id="btn-not-cancel" class="btn btn-success" value="2">注销取消</button>--%>
							<%--<button type="button" id="btn-not-lock" class="btn btn-success" value="4">锁定取消</button>--%>
						</div>
						<div class="jqGrid_wrapper">
							<table id="table_user"></table>
							<div id="pager_user"></div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>

	<table id="newsList" lay-filter="newsList"></table>
	<c:if test="${User.type eq '2'  }">
<!-- 底部导航开始 -->
<%@include file="/WEB-INF/common/footer.jsp"%>
<!-- 底部导航结束 -->
</c:if> 
	<%@include file="/WEB-INF/common/hplus-js.jsp"%>
	<!-- Peity -->
	<script src="${path}/assets/hplus/js/plugins/peity/jquery.peity.min.js"></script>
	<!-- jqGrid -->
	<script
		src="${path}/assets/hplus/js/plugins/jqgrid/i18n/grid.locale-cn.js?0820"></script>
	<script
		src="${path}/assets/hplus/js/plugins/jqgrid/jquery.jqGrid.min.js?0820"></script>

	<!-- 自定义js -->
	<script src="${path}/assets/hplus/js/content.js?v=1.0.0"></script>

	<script type="text/javascript"
		src="${path}/assets/hplus/js/plugins/layer/laydate/laydate.js"></script>

	<!-- Page-Level Scripts -->
	<script>

        // laydate({ elem: "#startDate", event: "focus" });
        // laydate({ elem: "#endDate", event: "focus" });
        // laydate({ elem: "#validityTime", event: "focus" });
        //laydate({ elem: "#applyTime", event: "focus" });

        $(document).ready(function () {
            $.jgrid.defaults.styleUI = 'Bootstrap';
            $("#table_user").jqGrid({
            	url : "${path}/article/query",
                mtype : "POST",
                datatype : "JSON",
                jsonReader:{
                   		id: "id", //相当于设置主键
		            	root: "result", //Json数据
		                total: "allPage",　　 //总页数
		                　　　　page: "page",　　//当前页
		                　　　　records: "allCount",//总记录数
		               repeatitems: false
                },
                
                altRows: true,//单双行样式不同
                altclass: 'differ',
                autowidth: true,
                shrinkToFit: true,
                
                /* multiselect:true, */
                height:353,
                rowNum: 10,
                uniqueId: "id",
                rowList: [10, 20, 30],
                colNames: ['标题', '封面','类别名称', '发布状态', '发布人','创建时间','更新时间','操作'],
                colModel: [
                  
                    {
                        name: 'title',
                        index: 'title',
                        width: 180,
                    },
                    {
                        name: 'coverImageUrl',
                        index: 'coverImageUrl',
                        width: 200,
                    },
                    {
                        name: 'genreName',
                        index: 'genreName',
                        align: 'center'
                    },
                    {
                        name: 'status',
                        index: 'status',
                        width: 190,
                    },
                   {
                    	name: 'addUserId',
                        index: 'addUserId',
                        width: 190,                   
                    },
                    {
                    	name: 'createDate',
                        index: 'createDate',
                        width: 190,
                    },
                    {
                    	name: 'updateDate',
                        index: 'updateDate',
                        width: 190,
                    },
                    {
                        name: 'operator',
                        index: 'operator',
                        width: 400,
                        formatter:function(cellvalue, options, rowObject){

                            var html = "";

                            if (rowObject.recordStatus == 5){
                                
                            }else {
                                if (rowObject.recordStatus == 3){
                                   
                                } else {
                                    html += "<a class='btn btn-primary btn-xs' style='margin-left:2px;font-size:10px;' onclick=\"editArticle('"+rowObject.id+"')\">编辑</a >"
                                    html += "<a class='btn btn-primary btn-xs' style='margin-left:2px;font-size:10px;' onclick=\"enableArticle('"+rowObject.id+"','"+rowObject.title+"')\">删除</a >"
                                   
                                }


                            }


                            return html;
                        }
                    }
                ],
                pager: "#pager_user",
                viewrecords: true,
                hidegrid: false
            });
            $(window).bind('resize', function () {
                var width = $('.jqGrid_wrapper').width();
                $('#table_user').setGridWidth(width);
            });
            $(window).trigger("resize");


            <%--$("#btn-not-lock").click(function(){--%>
                <%--var id= $('#table_user').jqGrid('getGridParam','selrow');--%>
                <%--console.log(id);--%>
                <%--if (id == null || id.length < 1) {--%>
                    <%--layer.msg('请选择您要取消锁定的车辆');--%>
                    <%--return;--%>
                <%--}--%>
                <%--parent.layer.confirm("您确定要取消锁定该车辆吗?", {--%>
                    <%--btn: ['确定','取消'], //按钮--%>
                    <%--shade: true, //不显示遮罩--%>
                    <%--shadeClose: true,--%>
                    <%--shade: 0.5,--%>
                <%--}, function(){--%>
                    <%--$.ajax({--%>
                        <%--type: "POST",--%>
                        <%--url: "${path}/car/lock",--%>
                        <%--data:{"status":4,"id":id},--%>
                        <%--dataType: "json",--%>
                        <%--success: function(json){--%>
                            <%--if(json.code == 0){--%>
                                <%--parent.layer.closeAll();--%>
                                <%--layer.msg('取消锁定成功', {icon: 1});--%>
                                <%--setTimeout(function(){--%>
                                    <%--location.reload();--%>
                                <%--}, 500);--%>
                            <%--}else{--%>
                                <%--layer.msg('取消锁定发生错误:' + json.msg, {icon: 5});--%>
                            <%--}--%>
                        <%--}--%>
                    <%--});--%>

                <%--}, function(){--%>

                <%--});--%>

            <%--});--%>

            $("#btn-add").click(function(){
            	/* layer.open({
                    type: 2,
                    title: '添加公告信息',
                    shadeClose: true,
                    shade: 0.5,
                    area: ['1300px', '550px'],
                    content: '${path}/article/add' //iframe的url
                }); */
                window.location.href="${path}/article/add";
            });
            
            $("#btn-query").click(function(){
            	$("#table_user").jqGrid('setGridParam', {
                    url : "${path}/article/query",
                    datatype:'json',
                    postData : {
                    	"title":$("#title").val(),
                    	"status":$("#status option:selected").val(),              
                    	"genreCode":$("#genreCode option:selected").val()
                    }, 
                    page : 1
                }).trigger("reloadGrid"); //重新载入
            });
         
        });
        function editArticle(id){
            layer.open({
                type: 2,
                title: '修改公告内容信息',
                shadeClose: true,
                shade: 0.5,
                area: ['1000px', '500px'],
                content: '${path}/article/edit/' + id //iframe的url
            });
        }

        function enableArticle(id,title){
        	parent.layer.confirm("您确定要删除"+title+"该公告内容信息吗?", {
        	    btn: ['确定','取消'], //按钮
        	    shade: true, //不显示遮罩
        	    shadeClose: true,
                shade: 0.5,
        	}, function(){
        		$.ajax({
                    type: "POST",
                    url: "${path}/article/enable",
                    data:{"id":id},
                    dataType: "json",
                    success: function(json){
                        if(json.code == 0){
                        	parent.layer.closeAll();
                        	setTimeout(function(){
                                location.reload();
                            }, 500); 
                        }else{
                        	layer.msg('发生错误:' + json.msg, {icon: 5});
                        }                    
                    }
                });
        		 
        	}, function(){
        	    
        	});
        }
	
            

    </script>
</body>
</html>
